<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Matrix207&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Matrix207's Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Matrix207's Blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Matrix207's Blog">
  
    <link rel="alternate" href="/atom.xml" title="Matrix207&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Matrix207&#39;s Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-how-to-implement-malloc" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/17/how-to-implement-malloc/" class="article-date">
  <time datetime="2016-07-16T17:38:00.000Z" itemprop="datePublished">2016-07-17</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="0x01-介绍"><a href="#0x01-介绍" class="headerlink" title="0x01 介绍"></a>0x01 介绍</h3><h3 id="0x02-分析"><a href="#0x02-分析" class="headerlink" title="0x02 分析"></a>0x02 分析</h3><h3 id="0x03-实现"><a href="#0x03-实现" class="headerlink" title="0x03 实现"></a>0x03 实现</h3><h3 id="0x04-参考"><a href="#0x04-参考" class="headerlink" title="0x04 参考"></a>0x04 参考</h3><ul>
<li><a href="http://blog.codinglabs.org/articles/a-malloc-tutorial.html" target="_blank" rel="external">http://blog.codinglabs.org/articles/a-malloc-tutorial.html</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/07/17/how-to-implement-malloc/" data-id="ciqqpe1d80003nmpvkpreezhu" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-study-grep-more" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/17/study-grep-more/" class="article-date">
  <time datetime="2016-07-16T16:58:00.000Z" itemprop="datePublished">2016-07-17</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/17/study-grep-more/">grep工作原理</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="0x01-介绍"><a href="#0x01-介绍" class="headerlink" title="0x01 介绍"></a>0x01 介绍</h3><p>GNU grep</p>
<h3 id="0x02-编译源码包"><a href="#0x02-编译源码包" class="headerlink" title="0x02 编译源码包"></a>0x02 编译源码包</h3><ul>
<li>source code <code>git clone git://git.savannah.gnu.org/grep.git</code></li>
</ul>
<h3 id="0x03-实现分析"><a href="#0x03-实现分析" class="headerlink" title="0x03 实现分析"></a>0x03 实现分析</h3><ul>
<li>GNU grep 不会检查每个字节</li>
<li>使用更少的指令检查数据</li>
<li>显示结果设计，颜色高亮</li>
</ul>
<h3 id="0x04-字符串搜索算法比较"><a href="#0x04-字符串搜索算法比较" class="headerlink" title="0x04 字符串搜索算法比较"></a>0x04 字符串搜索算法比较</h3><ul>
<li>Knuth-Morris-Pratt算法 (简称KMP算法)<br>是以三个发明者命名，其中Knuth是指Donald Knuth, 《计算机程序设计艺术》的作者</li>
<li>Boyer-Moore算法 (也称BM算法)</li>
</ul>
<h3 id="0x05-参考"><a href="#0x05-参考" class="headerlink" title="0x05 参考"></a>0x05 参考</h3><ul>
<li><a href="https://www.gnu.org/software/grep/" target="_blank" rel="external">GNU Grep</a></li>
<li><a href="https://www.gnu.org/software/grep/devel.html" target="_blank" rel="external">GNU Grep Development</a></li>
<li><a href="http://www.ruanyifeng.com/blog/2013/05/Knuth–Morris–Pratt_algorithm.html" target="_blank" rel="external">字符串匹配的KMP算法</a></li>
<li><a href="http://www.ruanyifeng.com/blog/2013/05/boyer-moore_string_search_algorithm.html" target="_blank" rel="external">字符串匹配的Boyer-Moore算法</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/07/17/study-grep-more/" data-id="ciqqpe1dd0006nmpvim32jqnx" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/tools/">tools</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-2016-04-13-malloc" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/07/17/2016-04-13-malloc/" class="article-date">
  <time datetime="2016-07-16T16:06:07.292Z" itemprop="datePublished">2016-07-17</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/07/17/2016-04-13-malloc/">malloc</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Algorithms"><a href="#Algorithms" class="headerlink" title="Algorithms"></a>Algorithms</h3><p>The main properties of the algorithms are:</p>
<ul>
<li>For large (&gt;= 512 bytes) requests, it is a pure best-fit allocator,<br>with ties normally decided via FIFO (i.e. least recently used).</li>
<li>For small (&lt;= 64 bytes by default) requests, it is a caching<br>allocator, that maintains pools of quickly recycled chunks.</li>
<li>In between, and for combinations of large and small requests, it does<br>the best it can trying to meet both goals at once.</li>
<li>For very large requests (&gt;= 128KB by default), it relies on system<br>memory mapping facilities, if supported.</li>
</ul>
<h3 id="Test"><a href="#Test" class="headerlink" title="Test"></a>Test</h3><ul>
<li><p>test code</p>
<pre><code>// gcc -o t t.c
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])

void test(size_t require)
{
    char* p = malloc(require);
    char* q = malloc(1);
    size_t size = malloc_usable_size(p);
    printf(&quot;memory require %lu, allocated %lu, address %p, next address %p, dis %ld\n&quot;,
            require, size, p, q, q-p);
    free(p);
    free(q);
}

int main()
{
    int fast_bin[] = {1, 2, 4, 8, 20, 24};
    int small_bin[] = {25, 30, 40, 41, 50, 60, 64, 70, 72, 73};
    int large_bin[] = {1024, 128*1024, 135*1024, 256*1024, 512*1024, 1024*1024};
    int i=0;
    printf(&quot;-----------Fast bin: memory pool-------------\n&quot;);
    for (i=0;i&lt;ARRAY_SIZE(fast_bin);i++) {
        test(fast_bin[i]);
    }
    printf(&quot;-----------Samll bin-------------\n&quot;);
    for (i=0;i&lt;ARRAY_SIZE(small_bin);i++) {
        test(small_bin[i]);
    }
    printf(&quot;-----------Large bin-------------\n&quot;);
    for (i=0;i&lt;ARRAY_SIZE(large_bin);i++) {
        test(large_bin[i]);
    }
    return 0;
}
</code></pre></li>
<li><p>test</p>
<pre><code>dennis@dennis:~/tt$ ./t
-----------Fast bin-------------
memory require 1, allocated 24, address 0x6ea010, next address 0x6ea030, dis 32
memory require 2, allocated 24, address 0x6ea030, next address 0x6ea010, dis -32
memory require 4, allocated 24, address 0x6ea010, next address 0x6ea030, dis 32
memory require 8, allocated 24, address 0x6ea030, next address 0x6ea010, dis -32
memory require 20, allocated 24, address 0x6ea010, next address 0x6ea030, dis 32
memory require 24, allocated 24, address 0x6ea030, next address 0x6ea010, dis -32
-----------Samll bin-------------
memory require 25, allocated 40, address 0x6ea050, next address 0x6ea010, dis -64
memory require 30, allocated 40, address 0x6ea050, next address 0x6ea010, dis -64
memory require 40, allocated 40, address 0x6ea050, next address 0x6ea010, dis -64
memory require 41, allocated 56, address 0x6ea080, next address 0x6ea010, dis -112
memory require 50, allocated 56, address 0x6ea080, next address 0x6ea010, dis -112
memory require 60, allocated 72, address 0x6ea0c0, next address 0x6ea010, dis -176
memory require 64, allocated 72, address 0x6ea0c0, next address 0x6ea010, dis -176
memory require 70, allocated 72, address 0x6ea0c0, next address 0x6ea010, dis -176
memory require 72, allocated 72, address 0x6ea0c0, next address 0x6ea010, dis -176
memory require 73, allocated 88, address 0x6ea110, next address 0x6ea010, dis -256
-----------Large bin-------------
memory require 1024, allocated 1032, address 0x6ea010, next address 0x6ea420, dis 1040
memory require 102400, allocated 102408, address 0x6ea010, next address 0x703020, dis 102416
memory require 131072, allocated 131080, address 0x6ea010, next address 0x70a020, dis 131088
memory require 262144, allocated 266224, address 0x7f0fc1283010, next address 0x6ea010, dis -139705634623488
memory require 524288, allocated 528368, address 0x7f0fc1243010, next address 0x6ea010, dis -139705634361344
memory require 1048576, allocated 1052656, address 0x7f0fc11c3010, next address 0x6ea010, dis -139705633837056
</code></pre></li>
</ul>
<p>When require memory size less than 24, use fastbin to allocate memory;<br>When require size large than 24, use smallbin</p>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><strong><a href="https://sploitfun.wordpress.com/2015/02/10/understanding-glibc-malloc/" target="_blank" rel="external">Understanding glibc malloc</a></strong></li>
<li><strong><a href="http://tyrande000.how/2016/02/20/linux下的堆管理/" target="_blank" rel="external">Linux下的堆管理</a></strong></li>
<li><strong><a href="http://www.valleytalk.org/wp-content/uploads/2015/02/glibc内存管理ptmalloc源代码分析1.pdf" target="_blank" rel="external">http://www.valleytalk.org/wp-content/uploads/2015/02/glibc内存管理ptmalloc源代码分析1.pdf</a></strong></li>
<li><strong><a href="https://github.com/lattera/glibc" target="_blank" rel="external">https://github.com/lattera/glibc</a></strong></li>
<li><a href="http://zmrlinux.com/category/linux-kernrl/mm/page/3/" target="_blank" rel="external">内存管理</a></li>
<li><a href="http://luodw.cc/2016/02/17/malloc/" target="_blank" rel="external">http://luodw.cc/2016/02/17/malloc/</a></li>
<li><a href="http://blog.csdn.net/ordeder/article/details/41654509" target="_blank" rel="external">http://blog.csdn.net/ordeder/article/details/41654509</a></li>
<li><a href="http://stackoverflow.com/questions/8367001/how-to-check-heap-size-for-a-process-on-linux" target="_blank" rel="external">http://stackoverflow.com/questions/8367001/how-to-check-heap-size-for-a-process-on-linux</a></li>
<li><a href="http://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c" target="_blank" rel="external">http://stackoverflow.com/questions/1281686/determine-size-of-dynamically-allocated-memory-in-c</a></li>
<li><a href="http://read.pudn.com/downloads92/doc/360828/Linux下动态内存分配安全性分析.pdf" target="_blank" rel="external">http://read.pudn.com/downloads92/doc/360828/Linux下动态内存分配安全性分析.pdf</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/07/17/2016-04-13-malloc/" data-id="ciqpd87uk00hkk0pv546tez3d" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/malloc/">malloc</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-include-what-you-use" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/04/27/include-what-you-use/" class="article-date">
  <time datetime="2016-04-26T16:14:26.000Z" itemprop="datePublished">2016-04-27</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="0x01-介绍"><a href="#0x01-介绍" class="headerlink" title="0x01 介绍"></a>0x01 介绍</h3><p>IWYU 是include what you use的首字母缩写<br>IWYU 使用clang分析符号的引用。是google的一个项目，它可以给出应该引用和移除<br>的头文件，但并不能保证 100% 是正确的（当然都是语言特性的原因）。</p>
<h3 id="0x02-编译源码包"><a href="#0x02-编译源码包" class="headerlink" title="0x02 编译源码包"></a>0x02 编译源码包</h3><ul>
<li>安装clang</li>
<li><p>检查clang的版本并下载对应版本的IWYU源码</p>
<ul>
<li><p><a href="https://github.com/include-what-you-use/include-what-you-use/releases" target="_blank" rel="external">https://github.com/include-what-you-use/include-what-you-use/releases</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">dennis@dennis:~/Downloads/build$ clang --version</div><div class="line">Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)</div><div class="line">Target: x86_64-pc-linux-gnu</div><div class="line">Thread model: posix</div></pre></td></tr></table></figure>
</li>
<li><p>当前系统使用的clang版本是3.4</p>
</li>
</ul>
</li>
<li>编译<ul>
<li><code>tar xvf include-what-you-use-clang_3.4.tar.gz</code></li>
<li><code>mkdir build &amp;&amp; cd build</code></li>
<li><code>cmake -G &quot;Unix Makefiles&quot; -DLLVM_PATH=/usr/lib/llvm-3.4 ../include-what-you-use-clang_3.4</code></li>
<li><code>make</code></li>
</ul>
</li>
</ul>
<h3 id="0x03-举例"><a href="#0x03-举例" class="headerlink" title="0x03 举例"></a>0x03 举例</h3><ul>
<li><p>c++ 源码 mem.cc</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">#include &lt;fcntl.h&gt;</div><div class="line">#include &lt;signal.h&gt;</div><div class="line">#include &lt;stdio.h&gt;</div><div class="line">//#include &lt;stdlib.h&gt;</div><div class="line">#include &lt;string.h&gt;</div><div class="line">#include &lt;stdint.h&gt;</div><div class="line">#include &lt;sys/mman.h&gt;</div><div class="line">#include &lt;sys/stat.h&gt;</div><div class="line">#include &lt;unistd.h&gt;</div><div class="line">#include &lt;sys/user.h&gt;</div><div class="line">#include &lt;execinfo.h&gt;</div><div class="line"></div><div class="line">#include &lt;thread&gt;</div><div class="line">using namespace std;</div><div class="line"></div><div class="line">void g()</div><div class="line">&#123;</div><div class="line">	usleep(2000);</div><div class="line">	printf(&quot;thread one\n&quot;);</div><div class="line">&#125;</div><div class="line"></div><div class="line">void f()</div><div class="line">&#123;</div><div class="line">	printf(&quot;thread two\n&quot;);</div><div class="line">&#125;</div><div class="line"></div><div class="line">int main(int argc, char* argv[])</div><div class="line">&#123;</div><div class="line">	std::thread t1(f);</div><div class="line">	std::thread t2(g);</div><div class="line">	t1.join();</div><div class="line">	t2.join();</div><div class="line">	return 0;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
<li><p>检查, 注意,要使用<code>-std=c++11</code>, 因为这里使用c11的线程库</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">dennis@dennis:~/Downloads/build$ ./include-what-you-use -std=c++11 mem.cc </div><div class="line"></div><div class="line">mem.cc should add these lines:</div><div class="line"></div><div class="line">mem.cc should remove these lines:</div><div class="line">- #include &lt;execinfo.h&gt;  // lines 11-11</div><div class="line">- #include &lt;fcntl.h&gt;  // lines 1-1</div><div class="line">- #include &lt;signal.h&gt;  // lines 2-2</div><div class="line">- #include &lt;stdint.h&gt;  // lines 6-6</div><div class="line">- #include &lt;string.h&gt;  // lines 5-5</div><div class="line">- #include &lt;sys/mman.h&gt;  // lines 7-7</div><div class="line">- #include &lt;sys/stat.h&gt;  // lines 8-8</div><div class="line">- #include &lt;sys/user.h&gt;  // lines 10-10</div><div class="line"></div><div class="line">The full include-list for mem.cc:</div><div class="line">#include &lt;stdio.h&gt;                      // for printf</div><div class="line">#include &lt;unistd.h&gt;                     // for usleep</div><div class="line">#include &lt;thread&gt;                       // for thread</div><div class="line">---</div></pre></td></tr></table></figure>
</li>
<li><p>修改</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">//#include &lt;fcntl.h&gt;</div><div class="line">//#include &lt;signal.h&gt;</div><div class="line">#include &lt;stdio.h&gt;</div><div class="line">//#include &lt;stdlib.h&gt;</div><div class="line">//#include &lt;string.h&gt;</div><div class="line">//#include &lt;stdint.h&gt;</div><div class="line">//#include &lt;sys/mman.h&gt;</div><div class="line">//#include &lt;sys/stat.h&gt;</div><div class="line">#include &lt;unistd.h&gt;</div><div class="line">//#include &lt;sys/user.h&gt;</div><div class="line">//#include &lt;execinfo.h&gt;</div></pre></td></tr></table></figure>
</li>
<li><p>再次检查,显示已正确引用或前向声明</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">dennis@dennis:~/Downloads/build$ ./include-what-you-use -std=c++11 mem.cc </div><div class="line"></div><div class="line">(mem.cc has correct #includes/fwd-decls)</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="0x04-参考"><a href="#0x04-参考" class="headerlink" title="0x04 参考"></a>0x04 参考</h3><ul>
<li><a href="http://xinsuiyuer.github.io/blog/2013/10/30/include-what-you-use/" target="_blank" rel="external">使用 I.W.Y.U 整理头文件引用</a></li>
<li><a href="https://github.com/include-what-you-use/include-what-you-use" target="_blank" rel="external">include-what-you-use</a><br>的头文件，但并不能保证 100% 是正确的，此 wiki Why Include What You Use Is Difficult 描述了其中的难点（当然都是语言特性的原因）。</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/04/27/include-what-you-use/" data-id="ciqpdqadb0000zxpv49zomt53" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-understand-gcc-assembly-output" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/04/24/understand-gcc-assembly-output/" class="article-date">
  <time datetime="2016-04-24T11:02:22.000Z" itemprop="datePublished">2016-04-24</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="0x00-generate-assembly-code-when-compile"><a href="#0x00-generate-assembly-code-when-compile" class="headerlink" title="0x00 generate assembly code when compile"></a>0x00 generate assembly code when compile</h3><p><code>gcc -S -o test.s test.c</code></p>
<p>sample code</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">#include &lt;stdio.h&gt;</div><div class="line"></div><div class="line">int main(int argc, char* argv[])</div><div class="line">&#123;</div><div class="line">	int i = 0;</div><div class="line">	for (i=0; i&lt;10; i++) &#123;</div><div class="line">		printf(&quot;hello123&quot;);</div><div class="line">	&#125;</div><div class="line">	return 0;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>assembly code:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line">	.file	&quot;test.c&quot;</div><div class="line">	.section	.rodata</div><div class="line">.LC0:</div><div class="line">	.string	&quot;hello123&quot;</div><div class="line">	.text</div><div class="line">	.globl	main</div><div class="line">	.type	main, @function</div><div class="line">main:</div><div class="line">.LFB0:</div><div class="line">	.cfi_startproc</div><div class="line">	pushq	%rbp</div><div class="line">	.cfi_def_cfa_offset 16</div><div class="line">	.cfi_offset 6, -16</div><div class="line">	movq	%rsp, %rbp</div><div class="line">	.cfi_def_cfa_register 6</div><div class="line">	subq	$32, %rsp</div><div class="line">	movl	%edi, -20(%rbp)</div><div class="line">	movq	%rsi, -32(%rbp)</div><div class="line">	movl	$0, -4(%rbp)</div><div class="line">	movl	$0, -4(%rbp)</div><div class="line">	jmp	.L2</div><div class="line">.L3:</div><div class="line">	movl	$.LC0, %edi</div><div class="line">	movl	$0, %eax</div><div class="line">	call	printf</div><div class="line">	addl	$1, -4(%rbp)</div><div class="line">.L2:</div><div class="line">	cmpl	$9, -4(%rbp)</div><div class="line">	jle	.L3</div><div class="line">	movl	$0, %eax</div><div class="line">	leave</div><div class="line">	.cfi_def_cfa 7, 8</div><div class="line">	ret</div><div class="line">	.cfi_endproc</div><div class="line">.LFE0:</div><div class="line">	.size	main, .-main</div><div class="line">	.ident	&quot;GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4&quot;</div><div class="line">	.section	.note.GNU-stack,&quot;&quot;,@progbits</div></pre></td></tr></table></figure>
<h3 id="0x01-basic-acknowledge-of-assembly-AT-amp-T"><a href="#0x01-basic-acknowledge-of-assembly-AT-amp-T" class="headerlink" title="0x01 basic acknowledge of assembly [AT&amp;T]"></a>0x01 basic acknowledge of assembly [AT&amp;T]</h3><ul>
<li>Register</li>
<li>Move</li>
</ul>
<h3 id="0x02-Reference"><a href="#0x02-Reference" class="headerlink" title="0x02 Reference"></a>0x02 Reference</h3><ul>
<li><a href="https://www.recurse.com/blog/7-understanding-c-by-learning-assembly" target="_blank" rel="external">understanding C by learning assembly</a></li>
<li><a href="http://blog.csdn.net/yayong/article/details/170842" target="_blank" rel="external">X86汇编语言学习手记(1)</a></li>
<li><a href="http://www.cs.virginia.edu/~evans/cs216/guides/x86.html" target="_blank" rel="external">X86 Assembly Guide</a></li>
<li><a href="https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax" target="_blank" rel="external">https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/04/24/understand-gcc-assembly-output/" data-id="ciqpd87ux00hxk0pvi608ayyg" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/assembly/">assembly</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/gcc/">gcc</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-speed-up-cplusplus-compilation" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/04/24/speed-up-cplusplus-compilation/" class="article-date">
  <time datetime="2016-04-24T08:07:15.000Z" itemprop="datePublished">2016-04-24</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/04/24/speed-up-cplusplus-compilation/">speed up c++ compilation</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="How-c-compilor-work"><a href="#How-c-compilor-work" class="headerlink" title="How c++ compilor work?"></a>How c++ compilor work?</h3><h3 id="Speed-up-tips"><a href="#Speed-up-tips" class="headerlink" title="Speed up tips"></a>Speed up tips</h3><ul>
<li>check code<ul>
<li>Don’t include not needed headers, use forward declaration for class if possible</li>
<li>Pimpl (pointer to implementation), interface and implement do their job clear</li>
<li>Reduce interdependency</li>
<li>Clean not needed headers</li>
<li>inline and template</li>
<li>Guard Conditions</li>
</ul>
</li>
<li>other tips<ul>
<li>PCH (Previous Compile Header)</li>
<li>Unity Build</li>
<li>ccache</li>
</ul>
</li>
<li>compile resource<ul>
<li>parallel compile, compile multiple modules at the same times</li>
<li>use more faster computer</li>
<li>distribute compile</li>
</ul>
</li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="www.cnblogs.com/baiyanhuang/archive/2010/01/17/1730717.html">如何加快C++代码的编译速度</a></li>
<li><a href="http://stackoverflow.com/questions/373142/what-techniques-can-be-used-to-speed-up-c-compilation-times" target="_blank" rel="external">http://stackoverflow.com/questions/373142/what-techniques-can-be-used-to-speed-up-c-compilation-times</a></li>
<li><a href="https://segmentfault.com/a/1190000002790854" target="_blank" rel="external">怎样削减C++代码间依赖</a></li>
<li><a href="https://www.zhihu.com/question/42964826" target="_blank" rel="external">为什么C++编译速度比Java慢得多？</a></li>
<li><a href="https://www.reddit.com/comments/r9p4c" target="_blank" rel="external">Walter Bright on C++ Compilation Speed</a></li>
<li><a href="http://www.drdobbs.com/cpp/c-compilation-speed/228701711" target="_blank" rel="external">C++ Compilation Speed</a></li>
<li><a href="http://www.futurechips.org/tips-for-power-coders/how-to-trick-cc-compilers-into-generating-terrible-code.html" target="_blank" rel="external">How to trick C/C++ compilers into generating terrible code?</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/04/24/speed-up-cplusplus-compilation/" data-id="ciqpd87ut00huk0pvrnzw8z36" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-hexo" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/04/18/hexo/" class="article-date">
  <time datetime="2016-04-18T15:44:19.000Z" itemprop="datePublished">2016-04-18</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/blog/">blog</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/04/18/hexo/">Hexo</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Why-leave-jekyll-and-move-to-hexo"><a href="#Why-leave-jekyll-and-move-to-hexo" class="headerlink" title="Why leave jekyll and move to hexo"></a>Why leave jekyll and move to hexo</h3><ul>
<li>Jekyll<ul>
<li>markdown syntax parsing change on github, and after my modify it not work as<br>before (so sad ;( )</li>
<li>Jekyll use ruby</li>
</ul>
</li>
<li>hexo<ul>
<li>Hexo use node.js</li>
<li>Have good themes</li>
</ul>
</li>
</ul>
<h3 id="What-is-hexo"><a href="#What-is-hexo" class="headerlink" title="What is hexo"></a>What is hexo</h3><p>A fast, simple &amp; powerful blog framework<br>see <a href="https://hexo.io/" target="_blank" rel="external">https://hexo.io/</a> for more</p>
<h3 id="Installation"><a href="#Installation" class="headerlink" title="Installation"></a>Installation</h3><ul>
<li>Yum like operation system<ul>
<li>install npm (Nodejs package manager) by <code>su -c &#39;yum install npm.noarch -y&#39;</code></li>
<li>use commands which support by officer site: <a href="https://hexo.io/" target="_blank" rel="external">https://hexo.io/</a><ul>
<li><code>npm install hexo-cli -g</code>, notice: run the command by root permission, pay<br>more pattion and try it again if you network speed is too slowly.</li>
<li><code>hexo init blog</code></li>
<li><code>cd blog</code></li>
<li><code>npm install</code></li>
<li><code>hexo server</code></li>
</ul>
</li>
</ul>
</li>
<li><code>mkdir hexo</code></li>
<li><code>hexo init</code><ul>
<li>if fail to install dependences auto, install them manually.<ul>
<li><code>cat package.json</code>, and look at the object of dependencies, just install them</li>
<li><code>npm install xxx --save</code></li>
<li>you can list installed modules by <code>ls node_modules</code></li>
</ul>
</li>
</ul>
</li>
<li>modify _config.yml, here is my changes:<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div></pre></td><td class="code"><pre><div class="line">diff --git a/_config.yml b/_config.yml</div><div class="line">index 26c27e9..9b0b32c 100644</div><div class="line">--- a/_config.yml</div><div class="line">+++ b/_config.yml</div><div class="line">@@ -3,11 +3,12 @@</div><div class="line"> ## Source: https://github.com/hexojs/hexo/</div><div class="line"> </div><div class="line"> # Site</div><div class="line">-title: Hexo</div><div class="line">+title: Matrix207&apos;s Blog</div><div class="line"> subtitle:</div><div class="line"> description:</div><div class="line">-author: John Doe</div><div class="line">-language:</div><div class="line">+author: Matrix207</div><div class="line">+language: zh-Hans</div><div class="line">+#language:</div><div class="line"> timezone:</div><div class="line"> </div><div class="line"> # URL</div><div class="line">@@ -28,7 +29,7 @@ i18n_dir: :lang</div><div class="line"> skip_render:</div><div class="line"> </div><div class="line"> # Writing</div><div class="line">-new_post_name: :title.md # File name of new posts</div><div class="line">+new_post_name: :year-:month-:day-:title.md # File name of new posts</div><div class="line"> default_layout: post</div><div class="line"> titlecase: false # Transform title into titlecase</div><div class="line"> external_link: true # Open external links in new tab</div><div class="line">@@ -63,9 +64,17 @@ pagination_dir: page</div><div class="line"> # Extensions</div><div class="line"> ## Plugins: https://hexo.io/plugins/</div><div class="line"> ## Themes: https://hexo.io/themes/</div><div class="line">-theme: landscape</div><div class="line">+#theme: landscape</div><div class="line">+theme: hexo-theme-next/</div><div class="line"> </div><div class="line"> # Deployment</div><div class="line"> ## Docs: https://hexo.io/docs/deployment.html</div><div class="line"> deploy:</div><div class="line">-  type:</div><div class="line">+  type: git</div><div class="line">+  repository: github.com:matrix207/matrix207.github.com.git</div><div class="line">+  branch: master</div><div class="line">+</div><div class="line">+# Toc</div><div class="line">+toc:</div><div class="line">+  maxDepth: 3</div><div class="line">+</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="Select-theme-hexo-theme-next-or-landscape"><a href="#Select-theme-hexo-theme-next-or-landscape" class="headerlink" title="Select theme: hexo-theme-next or landscape"></a>Select theme: hexo-theme-next or landscape</h3><ul>
<li>compare these two themes, I like hexo-theme-next more than landscape.</li>
<li>clone hexo-theme-next<ul>
<li><code>cd themes</code></li>
<li><code>git clone https://github.com/iissnan/hexo-theme-next</code></li>
</ul>
</li>
</ul>
<h3 id="What-features-I-need"><a href="#What-features-I-need" class="headerlink" title="What features I need"></a>What features I need</h3><ul>
<li>menus</li>
</ul>
<h3 id="Tips-for-fixing-issues"><a href="#Tips-for-fixing-issues" class="headerlink" title="Tips for fixing issues"></a>Tips for fixing issues</h3><ul>
<li>The <code>node</code> is not the real node, use command <code>sudo apt-get install nodejs-legacy</code><ul>
<li>ref <a href="https://github.com/rauchg/slackin/issues/128" target="_blank" rel="external">https://github.com/rauchg/slackin/issues/128</a></li>
</ul>
</li>
<li>Not found tags for hexo-theme-next <ul>
<li>ref <a href="http://theme-next.iissnan.com/theme-settings.html#标签云页面" target="_blank" rel="external">http://theme-next.iissnan.com/theme-settings.html#标签云页面</a></li>
<li>ref <a href="http://ijiaober.github.io/2014/08/05/hexo/hexo-04/" target="_blank" rel="external">http://ijiaober.github.io/2014/08/05/hexo/hexo-04/</a></li>
</ul>
</li>
<li>Not found page directory<ul>
<li>ref <a href="http://www.imys.net/20150514/hexo-toc.html" target="_blank" rel="external">http://www.imys.net/20150514/hexo-toc.html</a></li>
</ul>
</li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="https://github.com/iissnan/hexo-theme-next" target="_blank" rel="external">https://github.com/iissnan/hexo-theme-next</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/04/18/hexo/" data-id="ciqpd87uo00hok0pvahgrrlbp" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/blog/">blog</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/">hexo</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-performance-optimization-of-cplusplus" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/12/performance-optimization-of-cplusplus/" class="article-date">
  <time datetime="2016-03-11T16:00:00.000Z" itemprop="datePublished">2016-03-12</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/12/performance-optimization-of-cplusplus/">performance optimization of C++</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Tools-for-detect-time-killer"><a href="#Tools-for-detect-time-killer" class="headerlink" title="Tools for detect time killer"></a>Tools for detect time killer</h3><ul>
<li><a href="http://oprofile.sourceforge.net/news/" target="_blank" rel="external">OProfile</a></li>
<li><a href="http://icl.cs.utk.edu/papi/" target="_blank" rel="external">PAPI</a></li>
</ul>
<h3 id="Tips-for-Performance-Improvement-Code-Optimization"><a href="#Tips-for-Performance-Improvement-Code-Optimization" class="headerlink" title="Tips for Performance Improvement Code Optimization"></a>Tips for Performance Improvement Code Optimization</h3><ul>
<li>Optimize Your Code using Appropriate Algorithm</li>
<li>Optimize Your Code for Memory</li>
<li>Using operators</li>
<li>If Condition Optimization<ul>
<li><code>if (a &amp;&amp; b)</code>， place <code>b</code> first if <code>b</code> is more likely to be false</li>
</ul>
</li>
<li>Problems with Functions</li>
<li>Optimizing Loops<ul>
<li>It is faster to test if something is equal to zero than to compare two<br>different numbers.</li>
</ul>
</li>
<li>Reference<ul>
<li><a href="http://www.thegeekstuff.com/2015/01/c-cpp-code-optimization" target="_blank" rel="external">http://www.thegeekstuff.com/2015/01/c-cpp-code-optimization</a></li>
<li><a href="http://stackoverflow.com/questions/2030189/general-c-performance-improvement-tips" target="_blank" rel="external">http://stackoverflow.com/questions/2030189/general-c-performance-improvement-tips</a></li>
</ul>
</li>
</ul>
<h3 id="memory-allocate-on-stack-or-heap"><a href="#memory-allocate-on-stack-or-heap" class="headerlink" title="memory allocate on stack or heap"></a>memory allocate on stack or heap</h3><p>Allocate memory on stack is more faster then heap cause of different architecture.<br>The heap is a far more complicated data structure than the stack.</p>
<p><strong>Ref:</strong></p>
<ul>
<li><a href="http://stackoverflow.com/questions/2264969/why-is-memory-allocation-on-heap-much-slower-than-on-stack" target="_blank" rel="external">http://stackoverflow.com/questions/2264969/why-is-memory-allocation-on-heap-much-slower-than-on-stack</a></li>
<li><a href="http://stackoverflow.com/questions/4974617/what-is-more-efficient-stack-memory-or-heap" target="_blank" rel="external">http://stackoverflow.com/questions/4974617/what-is-more-efficient-stack-memory-or-heap</a></li>
<li><a href="http://stackoverflow.com/questions/161053/which-is-faster-stack-allocation-or-heap-allocation" target="_blank" rel="external">http://stackoverflow.com/questions/161053/which-is-faster-stack-allocation-or-heap-allocation</a></li>
</ul>
<h3 id="vector-vs-array"><a href="#vector-vs-array" class="headerlink" title="vector vs array"></a>vector vs array</h3><ul>
<li>Have same assembly instruction<ul>
<li>index operation is same</li>
<li>dereference operation is same</li>
<li>increment operation is same</li>
<li><a href="http://stackoverflow.com/questions/381621/using-arrays-or-stdvectors-in-c-whats-the-performance-gap" target="_blank" rel="external">http://stackoverflow.com/questions/381621/using-arrays-or-stdvectors-in-c-whats-the-performance-gap</a></li>
</ul>
</li>
<li>But there are some attributes make vector slower than C array<ul>
<li>Vector possible to store data in non-continuous chunk of memory</li>
<li>Vector allocate memory on heap always</li>
<li><a href="http://assoc.tumblr.com/post/411601680/performance-of-stl-vector-vs-plain-c-arrays" target="_blank" rel="external">http://assoc.tumblr.com/post/411601680/performance-of-stl-vector-vs-plain-c-arrays</a></li>
</ul>
</li>
<li>Another performance test between vector , boost array and C array<ul>
<li><a href="http://www.cnblogs.com/mudoot/articles/boost_array_0001.html" target="_blank" rel="external">http://www.cnblogs.com/mudoot/articles/boost_array_0001.html</a></li>
</ul>
</li>
</ul>
<h3 id="Use-the-right-container"><a href="#Use-the-right-container" class="headerlink" title="Use the right container"></a>Use the right container</h3><ul>
<li>more container compare and select<ul>
<li>vector is good at read data</li>
<li>list is good at insert and remove data</li>
<li>deque has good balance for read, insert and remove data</li>
<li><a href="http://www.cppblog.com/sailing/articles/161659.html" target="_blank" rel="external">http://www.cppblog.com/sailing/articles/161659.html</a></li>
</ul>
</li>
<li>reference<ul>
<li><a href="http://stackoverflow.com/questions/3664272/is-stdvector-so-much-slower-than-plain-arrays" target="_blank" rel="external">http://stackoverflow.com/questions/3664272/is-stdvector-so-much-slower-than-plain-arrays</a></li>
</ul>
</li>
</ul>
<h3 id="Some-tips-when-using-C"><a href="#Some-tips-when-using-C" class="headerlink" title="Some tips when using C++"></a>Some tips when using C++</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">class Foo</div><div class="line">&#123;</div><div class="line">    const BigObject &amp; bar();</div><div class="line">&#125;;</div><div class="line"></div><div class="line">BigObject obj = foo.bar();  // OOPS!  This creates a copy!</div><div class="line">const BigOject &amp;obj = foo.bar();  // does not create a copy</div></pre></td></tr></table></figure>
<h3 id="some-books"><a href="#some-books" class="headerlink" title="some books"></a>some books</h3><ul>
<li>Effective C++</li>
<li>More Effective C++</li>
<li>Effective STL</li>
<li>C++ Coding Standards</li>
<li>Efficient C++: Performance Programming Techniques</li>
</ul>
<h3 id="Know-some-compile-and-linker-options"><a href="#Know-some-compile-and-linker-options" class="headerlink" title="Know some compile and linker options"></a>Know some compile and linker options</h3><ul>
<li>gcc</li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><strong><a href="https://en.wikibooks.org/wiki/Optimizing_C++" target="_blank" rel="external">https://en.wikibooks.org/wiki/Optimizing_C++</a></strong></li>
<li><strong><a href="http://agner.org/optimize/optimizing_cpp.pdf" target="_blank" rel="external">http://agner.org/optimize/optimizing_cpp.pdf</a></strong></li>
<li><a href="http://www.artima.com/cppsource/how_to_go_slow.html" target="_blank" rel="external">http://www.artima.com/cppsource/how_to_go_slow.html</a></li>
<li><a href="https://github.com/fffaraz/awesome-cpp" target="_blank" rel="external">https://github.com/fffaraz/awesome-cpp</a></li>
<li><a href="https://notabug.org/koz.ross/awesome-c" target="_blank" rel="external">https://notabug.org/koz.ross/awesome-c</a></li>
<li><a href="https://github.com/jobbole/awesome-c-cn" target="_blank" rel="external">https://github.com/jobbole/awesome-c-cn</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/12/performance-optimization-of-cplusplus/" data-id="ciqqpe1vh00f1nmpvrygz86iu" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/performance/">performance</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-check-pow-overflow" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/09/check-pow-overflow/" class="article-date">
  <time datetime="2016-03-08T16:00:00.000Z" itemprop="datePublished">2016-03-09</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/09/check-pow-overflow/">check pow overflow</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Source-code"><a href="#Source-code" class="headerlink" title="Source code"></a>Source code</h3><pre><code>// Create by matrix207 2016-03-09
// g++ -o t check-pow-overflow.cc

#include &lt;iostream&gt;
#include &lt;typeinfo&gt;
#include &lt;cmath&gt;
#include &lt;limits&gt;

/*
 * Check if pow overflow for type T (int,float,long,double)
 * a^b &lt;= m  &lt;=&gt; log(a^b) &lt;= log(m) &lt;=&gt; b*log(a) &lt;= log(m) &lt;=&gt; b &lt;= log(m)/log(a)
 * @param a
 *     base number
 * @param b
 *     exponent number
 * @return
 *     1 if overflow, otherwise 0
 */
template&lt;typename T1, typename T2&gt;
int check_pow(T1 a, T2 b)
{
    int ret = 0;
    // i:int, f:float, d:double, l:long
    std::cout &lt;&lt; &quot;Type: &quot; &lt;&lt; typeid(a).name() &lt;&lt; &quot;,&quot; &lt;&lt; typeid(b).name() &lt;&lt; &quot; &quot;;
    double max_a = std::log(std::numeric_limits&lt;T1&gt;::max());
    double max_b = std::log(std::numeric_limits&lt;T2&gt;::max());
    double max_max = max_a &lt; max_b ? max_b : max_a;
    if (b * std::log(a) &lt; max_max) {
        double c = std::pow(a, b);
        std::cout &lt;&lt; a &lt;&lt; &quot;^&quot; &lt;&lt; b &lt;&lt; &quot;=&quot; &lt;&lt; c &lt;&lt; std::endl;
    } else {
        std::cout &lt;&lt; a &lt;&lt; &quot;^&quot; &lt;&lt; b &lt;&lt; &quot; overflow&quot; &lt;&lt; std::endl;
        ret = 1;
    }
    return ret;
}

int main(int argc, char* argv[])
{
    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test int type &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(25, 1);
    check_pow(25, 10);
    check_pow(25, 100);
    check_pow(25, 1000);

    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test long type &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(25L, 1L);
    check_pow(25L, 10L);
    check_pow(25L, 100L);
    check_pow(25L, 1000L);

    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test float type &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(25.3f, 1.0f);
    check_pow(25.3f, 10.0f);
    check_pow(25.3f, 100.0f);
    check_pow(25.3f, 1000.0f);

    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test double type &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(25.3, 1.0);
    check_pow(25.3, 10.0);
    check_pow(25.3, 100.0);
    check_pow(25.3, 1000.0);

    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test mix type &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(25, 10.0); // int, double
    check_pow(25, 100.0); // int, double
    check_pow(25, 1000.0); // int, double
    check_pow(25.0f, 10.0); // float, double
    check_pow(25.0f, 100.0); // float, double
    check_pow(25.0f, 1000.0); // float, double

    std::cout &lt;&lt; &quot;\n&gt;&gt;&gt; Test others &lt;&lt;&lt;&quot; &lt;&lt; std::endl;
    check_pow(0, 100);
    check_pow(0, -2);
    check_pow(-1, -2);
    check_pow(-1, -20);
    check_pow(25, -20);

    return 0;
}
</code></pre><h3 id="Test"><a href="#Test" class="headerlink" title="Test"></a>Test</h3><pre><code>[dennis@localhost code]$ g++ -o t check-pow-overflow.cc
[dennis@localhost code]$ ./t

&gt;&gt;&gt; Test int type &lt;&lt;&lt;
Type: i,i 25^1=25
Type: i,i 25^10 overflow
Type: i,i 25^100 overflow
Type: i,i 25^1000 overflow

&gt;&gt;&gt; Test long type &lt;&lt;&lt;
Type: l,l 25^1=25
Type: l,l 25^10=9.53674e+13
Type: l,l 25^100 overflow
Type: l,l 25^1000 overflow

&gt;&gt;&gt; Test float type &lt;&lt;&lt;
Type: f,f 25.3^1=25.3
Type: f,f 25.3^10=1.0745e+14
Type: f,f 25.3^100 overflow
Type: f,f 25.3^1000 overflow

&gt;&gt;&gt; Test double type &lt;&lt;&lt;
Type: d,d 25.3^1=25.3
Type: d,d 25.3^10=1.0745e+14
Type: d,d 25.3^100=2.05141e+140
Type: d,d 25.3^1000 overflow

&gt;&gt;&gt; Test mix type &lt;&lt;&lt;
Type: i,d 25^10=9.53674e+13
Type: i,d 25^100=6.22302e+139
Type: i,d 25^1000 overflow
Type: f,d 25^10=9.53674e+13
Type: f,d 25^100=6.22302e+139
Type: f,d 25^1000 overflow

&gt;&gt;&gt; Test other &lt;&lt;&lt;
Type: i,i 0^100=0
Type: i,i 0^-2 overflow
Type: i,i -1^-2 overflow
Type: i,i -1^-20 overflow
Type: i,i 25^-20=1.09951e-28
</code></pre><h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="http://www.cplusplus.com/reference/cmath/pow/" target="_blank" rel="external">pow C++ Reference</a></li>
<li><a href="http://www.cplusplus.com/reference/cmath/log/" target="_blank" rel="external">log C++ Reference</a></li>
<li><a href="http://en.cppreference.com/w/cpp/numeric/math/pow" target="_blank" rel="external">std::pow</a></li>
<li><a href="http://en.cppreference.com/w/cpp/types/numeric_limits" target="_blank" rel="external">std::numeric_limits</a></li>
<li><a href="http://stackoverflow.com/questions/18609085/how-can-i-check-if-stdpow-will-overflow-double" target="_blank" rel="external">http://stackoverflow.com/questions/18609085/how-can-i-check-if-stdpow-will-overflow-double</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/09/check-pow-overflow/" data-id="ciqqpe1vb00eunmpv7ho7sgqx" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-stack-trace-when-program-crash" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/09/stack-trace-when-program-crash/" class="article-date">
  <time datetime="2016-03-08T16:00:00.000Z" itemprop="datePublished">2016-03-09</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/09/stack-trace-when-program-crash/">stack trace when program crash</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="Source"><a href="#Source" class="headerlink" title="Source"></a>Source</h4><pre><code>#include &lt;stdio.h&gt;
#include &lt;execinfo.h&gt;
#include &lt;signal.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;

void handler(int sig) {
    void *array[10];
    size_t size;

    // get void*&apos;s for all entries on the stack
    size = backtrace(array, 10);

    // print out all the frames to stderr
    fprintf(stderr, &quot;Error: signal %d:\n&quot;, sig);
    backtrace_symbols_fd(array, size, STDERR_FILENO);
    exit(1);
}

void baz() {
    int *foo = (int*)-1; // make a bad pointer
    printf(&quot;%d\n&quot;, *foo);       // causes segfault
}

void bar() { baz(); }
void foo() { bar(); }

int main(int argc, char **argv) {
    signal(SIGSEGV, handler);   // install our handler
    foo(); // this will call foo, bar, and baz.  baz segfaults.
}
</code></pre><h4 id="Compile-and-test"><a href="#Compile-and-test" class="headerlink" title="Compile and test"></a>Compile and test</h4><pre><code>[dennis@localhost code]$ gcc -g -rdynamic -o t stacktrace.c
[dennis@localhost code]$ ./t
Error: signal 11:
./t(handler+0x1c)[0x400a32]
/lib64/libc.so.6(+0x34960)[0x7fa03d30d960]
./t(baz+0x14)[0x400a8b]
./t(bar+0xe)[0x400aae]
./t(foo+0xe)[0x400abe]
./t(main+0x28)[0x400ae8]
/lib64/libc.so.6(__libc_start_main+0xf0)[0x7fa03d2f8fe0]
./t[0x400949]
</code></pre><h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h4><ul>
<li><a href="http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes" target="_blank" rel="external">http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/09/stack-trace-when-program-crash/" data-id="ciqqpe1ve00exnmpvaj31tuka" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/crash/">crash</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/stack/">stack</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><a class="extend next" rel="next" href="/page/2/">__('next') &raquo;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/english/">english</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/">kernel</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/language/">language</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/math/">math</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/network/">network</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/others/">others</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/person/">person</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/program/">program</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/source/">source</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/storage/">storage</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/tools/">tools</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/FAQ/">FAQ</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/IRC/">IRC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Translation/">Translation</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/api/">api</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/assembly/">assembly</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/awk/">awk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/batch/">batch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/book/">book</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crash/">crash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dot/">dot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/driver/">driver</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/emacs/">emacs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exploit/">exploit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/file-system/">file system</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flowchart/">flowchart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gcc/">gcc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/google/">google</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/graphviz/">graphviz</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hosts/">hosts</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/job/">job</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lisp/">lisp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/makefile/">makefile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/malloc/">malloc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/math/">math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maxima/">maxima</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory/">memory</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netdisk/">netdisk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/others/">others</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandoc/">pandoc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/performance/">performance</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/person/">person</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rsync/">rsync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/skype/">skype</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sms/">sms</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/source/">source</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/">ssh</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stack/">stack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/storage/">storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/study/">study</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svn/">svn</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sync/">sync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time/">time</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tools/">tools</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/valgrind/">valgrind</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vi/">vi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/virtual/">virtual</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wget/">wget</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows/">windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wireshark/">wireshark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/write/">write</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xml/">xml</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/tags/FAQ/" style="font-size: 10px;">FAQ</a> <a href="/tags/IRC/" style="font-size: 10px;">IRC</a> <a href="/tags/Translation/" style="font-size: 13px;">Translation</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/api/" style="font-size: 10px;">api</a> <a href="/tags/assembly/" style="font-size: 10px;">assembly</a> <a href="/tags/awk/" style="font-size: 11px;">awk</a> <a href="/tags/batch/" style="font-size: 14px;">batch</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/book/" style="font-size: 10px;">book</a> <a href="/tags/c/" style="font-size: 16px;">c</a> <a href="/tags/c/" style="font-size: 19px;">c++</a> <a href="/tags/cache/" style="font-size: 10px;">cache</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/database/" style="font-size: 17px;">database</a> <a href="/tags/debug/" style="font-size: 12px;">debug</a> <a href="/tags/dot/" style="font-size: 10px;">dot</a> <a href="/tags/driver/" style="font-size: 10px;">driver</a> <a href="/tags/emacs/" style="font-size: 11px;">emacs</a> <a href="/tags/exploit/" style="font-size: 10px;">exploit</a> <a href="/tags/file-system/" style="font-size: 10px;">file system</a> <a href="/tags/filesystem/" style="font-size: 12px;">filesystem</a> <a href="/tags/flowchart/" style="font-size: 10px;">flowchart</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 12px;">git</a> <a href="/tags/google/" style="font-size: 11px;">google</a> <a href="/tags/graphviz/" style="font-size: 11px;">graphviz</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hosts/" style="font-size: 10px;">hosts</a> <a href="/tags/iscsi/" style="font-size: 14px;">iscsi</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/job/" style="font-size: 10px;">job</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/kernel/" style="font-size: 14px;">kernel</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lisp/" style="font-size: 10px;">lisp</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/makefile/" style="font-size: 10px;">makefile</a> <a href="/tags/malloc/" style="font-size: 10px;">malloc</a> <a href="/tags/math/" style="font-size: 11px;">math</a> <a href="/tags/maxima/" style="font-size: 10px;">maxima</a> <a href="/tags/memory/" style="font-size: 11px;">memory</a> <a href="/tags/memory-overflow/" style="font-size: 10px;">memory overflow</a> <a href="/tags/mtrace/" style="font-size: 10px;">mtrace</a> <a href="/tags/netdisk/" style="font-size: 10px;">netdisk</a> <a href="/tags/network/" style="font-size: 20px;">network</a> <a href="/tags/others/" style="font-size: 18px;">others</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a> <a href="/tags/performance/" style="font-size: 16px;">performance</a> <a href="/tags/person/" style="font-size: 11px;">person</a> <a href="/tags/protobuf/" style="font-size: 11px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/rsync/" style="font-size: 10px;">rsync</a> <a href="/tags/sed/" style="font-size: 11px;">sed</a> <a href="/tags/shell/" style="font-size: 15px;">shell</a> <a href="/tags/skype/" style="font-size: 11px;">skype</a> <a href="/tags/sms/" style="font-size: 10px;">sms</a> <a href="/tags/source/" style="font-size: 11px;">source</a> <a href="/tags/ssh/" style="font-size: 10px;">ssh</a> <a href="/tags/stack/" style="font-size: 10px;">stack</a> <a href="/tags/storage/" style="font-size: 15px;">storage</a> <a href="/tags/study/" style="font-size: 10px;">study</a> <a href="/tags/svn/" style="font-size: 11px;">svn</a> <a href="/tags/sync/" style="font-size: 10px;">sync</a> <a href="/tags/test/" style="font-size: 11px;">test</a> <a href="/tags/time/" style="font-size: 10px;">time</a> <a href="/tags/tools/" style="font-size: 16px;">tools</a> <a href="/tags/valgrind/" style="font-size: 10px;">valgrind</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 14px;">vim</a> <a href="/tags/virtual/" style="font-size: 11px;">virtual</a> <a href="/tags/wget/" style="font-size: 10px;">wget</a> <a href="/tags/windows/" style="font-size: 11px;">windows</a> <a href="/tags/wireshark/" style="font-size: 10px;">wireshark</a> <a href="/tags/write/" style="font-size: 13px;">write</a> <a href="/tags/xml/" style="font-size: 10px;">xml</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">September 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">June 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/02/">February 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">January 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">September 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">August 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">July 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">June 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/04/">April 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/02/">February 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/12/">December 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/09/">September 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
          </li>
        
          <li>
            <a href="/2016/07/17/study-grep-more/">grep工作原理</a>
          </li>
        
          <li>
            <a href="/2016/07/17/2016-04-13-malloc/">malloc</a>
          </li>
        
          <li>
            <a href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
          </li>
        
          <li>
            <a href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Matrix207<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>